﻿@page "/handwritten"
@attribute [TabItemOption(Text = "手写签名")]

<h3>Handwritten 手写签名</h3>
<p>建议转为使用 SignaturePadPage组件</p>
<hr />
<a href="https://github.com/densen2014/Densen.Extensions/blob/master/Demo/DemoShared/Pages/HandwrittenPage.razor"><h5>页面源码</h5></a>

<button class="btn btn-primary"
        type="button"
        @onclick="(() => ShowHandwritten = !ShowHandwritten)">
    [签名]
</button>
<textarea type="text" class="form-control" style="min-width: 100px;" rows="10"
          @bind="DrawBase64"
          placeholder="Base64" />
@if (ShowHandwritten)
{

    <AmeBlazor.Components.Handwritten HandwrittenBase64="((e) => { DrawBase64=e; ShowHandwritten = !ShowHandwritten; })"
                                      Close="(()=>ShowHandwritten=!ShowHandwritten)" />

}
<AttributeTable Items="@GetAttributes()" />

@code{

    /// <summary>
    /// 显示签名界面
    /// </summary>
    bool ShowHandwritten { get; set; } = false;

    /// <summary>
    /// 签名Base64
    /// </summary>
    public string? DrawBase64 { get; set; }


    /// <summary>
    /// 获得属性方法
    /// </summary>
    /// <returns></returns>
    private IEnumerable<AttributeItem> GetAttributes() => new AttributeItem[]
    {
            new AttributeItem("HandwrittenBase64","签名结果回调方法",  "","EventCallback<string>") ,
            new AttributeItem("Close","关闭签名框回调方法",  "","EventCallback")
            };
}
